软考真题
第11题

阅读下列说明和C++代码,填写程序中的空(1)(6),将解答写入答题纸的对应栏内。  【说明】
以下C++代码实现一个简单绘图工具,绘制不同形状以及不同颜色的图形。部分类及其关系如图6-1所示。

 

【C++代码】

#include
#include
usingnamespacestd;
classDrawCircle {                       /* 绘制圆形,抽象类 */
public:
	(1) ;                           /* 定义参数为intradius, int x, int y */
	virtual ~ DrawCircle()
	{
	}
};

classRedCircle : publicDrawCircle {     /* 绘制红色圆形 */
public:
	voiddrawCircle( int radius, int x, int y )
	{
		cout << "DrawingCircle[red,radius: " < cout << ",x: " <
	}
};

classGreenCircle : publicDrawCircle { /* 绘制绿色圆形 */
public:
	voiddrawCircle( int radius, int x, int y )
	{
		cout << "DrawingCircle[green,radius: " < cout << ",x: " <
	}
};

classShape { /* 形状,抽象类 */
protected:
	(2);
public:
	Shape( DrawCircle * drawCircle )
	{
		this->drawCircle = drawCircle;
	}
	virtual ~ shape()
	{
	}
public:
	virtualvoiddraw() = 0;
};

classCircle : publicShape { /* 圆形 */
private:
	int x, y, radius;
public:
	Circle( int x, int y, int radius, DrawCircle * drawCircle ) (3)
	{
		this->x		= x;
		this->y		= y;
		this->radius	= radius;
	}
public:
	voiddraw()
	{
		drawCircle->(4);
	}
};

intmain()
{
	Shape	*redCircle = newCircle( 100, 100, 10, (5) );    /* 绘制红色圆形 */
	Shape	*greenCircle = newCircle( 100, 100, 10, (6) );  /* 绘制绿色圆形 */
	redCircle->draw();
	greenCircle->draw();
	return0;
}
【问题:6.1】
第10章C 程序设计
正确答案:
你的答案:
请先在App中激活(应用市场搜“软考真题”)
知识点:
试卷:
2018年 上半年 下午试卷 案例

笔记

Tekken

请先在App中激活(应用市场搜“软考真题”)

2023-03-22


答题卡
加油
纠错
得分:0